﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using websoniBO;

namespace websoni.Adminpages
{
    public partial class WebForm7 : System.Web.UI.Page
    {
        Personal p = new Personal();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnupdate.Visible = false;
                DataTable dt = p.GetRecords(-99,  "", false, " and ");
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            p.proid = -99;
            p.show = tbshowname.Text.Replace(Environment.NewLine,"</br>");
            p.isdeleted = false;
            p.SaveRecords();
            Response.Redirect("~/Adminpages/AProf.aspx");
        }

       

        protected void btnupdate_Click(object sender, EventArgs e)
        {
            p.proid = Convert.ToInt64(tbproid.Text);
            p.show = tbshowname.Text.Replace(Environment.NewLine,"</br>");
            p.isdeleted = false;
            p.SaveRecords();
            Response.Redirect("~/Adminpages/AProf.aspx");
        }

       
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }

        protected void btnedit_Command(object sender, CommandEventArgs e)
        {
            btnupdate.Visible = true;
            Button1.Visible = false;
            DataTable dte = p.GetRecords(Convert.ToInt64(e.CommandArgument), "", false, " and ");
            tbproid.Text = dte.Rows[0]["proid"].ToString();
            tbshowname.Text = dte.Rows[0]["show"].ToString().Replace("</br>",Environment.NewLine);
        }

        protected void btndelete_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                DataTable dtd = p.GetRecords(Convert.ToInt64(e.CommandArgument), "", false, " and ");
                p.proid = Convert.ToInt64(dtd.Rows[0]["proid"].ToString());
                p.show = dtd.Rows[0]["show"].ToString();
                p.isdeleted = true;
                p.SaveRecords();
                Response.Redirect("~/Adminpages/AProf.aspx");
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex= e.NewPageIndex;
            DataTable dt1 = p.GetRecords(-99, "", false, " and ");
            GridView1.DataSource = dt1;
            GridView1.DataBind();
        }

        
    }
}
